package com.leet.competition;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;

public class MinimumDifference {
    public int minimumDifference(int[] nums, int k) {
        Arrays.sort(nums);
        int i = 0,j = i+k;
        int ans = 0;
        while(j < nums.length){
            ans = Math.max(ans,nums[i+k]-nums[i]);
            i++;
            j++;
        }
        return ans;
    }
}
